package com.zlm.common.util;

import com.google.gson.Gson;

/**
 * 字符串转json工具类
 * @author xhj
 */
public class GsonUtils {

    //将bean转换成Json字符串
    public static String beanToJSONString(Object bean) {
        return new Gson().toJson(bean);
    }

    //将Json字符串转换成对象
    public static Object JSONToObject(String json, Class beanClass) {
        Gson gson = new Gson();
        Object res = gson.fromJson(json, beanClass);
        return res;
    }
}
